<template>
  <div class="mainCon">
    <topTitle :titleText="titleText" class="topConStyle"></topTitle>
    <div class="mainConHeader">
      <div class="mainConHeaderContent"></div>
      <el-tabs
        v-model="activeName"
        type="card"
        @tab-click="handleClick"
        class="commonTab"
      >
        <el-tab-pane
          :label="item.label"
          :name="item.id"
          v-for="item in list"
          :key="item.id"
        ></el-tab-pane>
      </el-tabs>
      <component v-bind:is="currentTabComponent" :status="status"></component>
    </div>
  </div>
</template>
<script>
import enterpriseRewardAndPunish from './enterpriseRewardAndPunish'
import personalRewardAndPunish from './personalRewardAndPunish'
export default {
  name: 'rewardAndPunish',
  components: {
    enterpriseRewardAndPunish,
    personalRewardAndPunish,
  },
  data() {
    return {
      titleText: '奖惩记录',
      activeName: '1',
      list: [
        {
          id: '1',
          label: '企业奖惩记录',
        },
        {
          id: '2',
          label: '个人奖惩记录',
        },
      ],
      currentTabComponent: 'enterpriseRewardAndPunish',
      status: '',
    }
  },
  created() {
    this.status = this.$route.query.status || ''
  },
  mounted() {
    //返回到当前tab栏
    if (this.$route.query.activeName == 2) {
      this.activeName = '2'
      this.currentTabComponent = personalRewardAndPunish
    } else {
      this.activeName = '1'
      this.currentTabComponent = enterpriseRewardAndPunish
    }
  },
  methods: {
    //tabs栏切换
    handleClick(tab, event) {
      if (this.activeName == 1) {
        this.currentTabComponent = enterpriseRewardAndPunish
      } else if (this.activeName == 2) {
        this.currentTabComponent = personalRewardAndPunish
      }
    },
  },
}
</script>

<style scoped lang="less">
.mainCon {
  top: 132px;
  padding: 0;
  &Header {
    position: relative;
    &Content {
      position: absolute;
      left: 130px;
      z-index: 100;
      font-size: 12px;
      color: #666666;
    }
  }
  .topConStyle {
    margin: 0 !important;
  }
}
</style>
